import {insertSql, selectSql} from "../util/sqlUtils";
import {UserInfo} from "../sql/domin";


export class UserMapper {
    public static insertUser = (userInfo: UserInfo): Promise<any> => {
        return insertSql('user', new Map<string, any>([
            ['id',userInfo.id],
            ['username', userInfo.username],
            ['password', userInfo.password],
            ['dept_id', userInfo.deptId],
            ['dept_name', userInfo.deptName],
            ['nickname', userInfo.nickname],
            ['role',userInfo.role]
        ]))
    }

    public static selectUserByUserName = (username: string): Promise<any> => {
        return selectSql('user', new Map([
            ['username', username]
        ]))
    }

    public static selectUserList = (): Promise<any> => {
        return selectSql('user')
    }

    public static selectUserById = (id: number): Promise<any> => {
        return selectSql('user', new Map([
            ['id', id]
        ]))
    }
}

